package com.itchu.common.config;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.profile.DefaultProfile;
import javafx.beans.DefaultProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(SmsProperties.class)
public class SmsConfiguration {

    /**
     * 相当于阿里短信服务文档的这两句
     *  DefaultProfile profile
     *      = DefaultProfile.getProfile("cn-hangzhou", "<accessKeyId>", "<accessSecret>");
     *         IAcsClient client = new DefaultAcsClient(profile);
     * @param prop
     * @return
     */
    @Bean
    public IAcsClient acsClient(SmsProperties prop) {
        DefaultProfile profile = DefaultProfile.getProfile(
                prop.getRegionID(),prop.getAccessKeyID(),prop.getAccessKeySecret());

        return new DefaultAcsClient(profile);
    }
}
